//#include <iostream>
//using namespace std;
//
//string a, b;
//
//void dfs(int l1, int r1, int l2, int r2)
//{
//	if (l1 > r1) return;
//	
//	int root = l1;
//	while (a[root] != b[l2]) root++;
//	
//	dfs(l1, root - 1, l2 + 1, l2 + 1 + root - l1 - 1);
//	dfs(root + 1, r1, l2 + 1 + root - l1, r2);
//	cout << b[l2];
//}
//
//int main()
//{
//	cin >> a >> b;
//	
//	dfs(0, a.size() - 1, 0, b.size() - 1);
//	
//	return 0;
//}



#include <iostream>
#include <vector>
#include <queue>
using namespace std;

const int N = 110;

int n, fa[N], dis[N];
vector<int> edges[N];

int dfs(int root)
{
	int ret = 0;
	for (auto v : edges[root])
	{
		ret = max(ret, dfs(v));
	}
	return ret + 1;
}

int bfs(int root)
{
	queue<int> q;
	q.push(root);
	
	int ret = 0;
	while (q.size())
	{
		int sz = q.size();
		ret = max(ret, sz);
		
		while (sz--)
		{
			int u = q.front(); q.pop();
			
			for (auto v : edges[u])
			{
				q.push(v);
			}
		}
	}
	
	return ret;
}

int ds(int x, int y)
{
	while (x != 1)
	{
		dis[fa[x]] = dis[x] + 1;
		x = fa[x];
	}
	
	int len = 0;
	while (y != 1 && dis[y] == 0)
	{
		len++;
		y = fa[y];
	}
	
	return dis[y] * 2 + len; 
}

int main()
{
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		int u, v; cin >> u >> v;
		edges[u].push_back(v);
		fa[v] = u;
	}
	
	cout << dfs(1) << endl;
	
	cout << bfs(1) << endl;
	
	int x, y; cin >> x >> y;
	
	cout << ds(x, y) << endl;
	
	return 0;
}
